home *** CD-ROM | disk | FTP | other *** search
/ CD/PC Actual 44 / PC Actual CD 44.iso / Linux / Cygwin / full.exe / Disk1 / data1.cab / Tools / H-i586-cygwin32 / bin / runtest < prev    next >
Encoding:
Text File  |  1998-12-04  |  2.7 KB  |  118 lines

  1. #!/bin/sh
  2. #
  3. # runtest -- basically all this script does is find the proper expect
  4. #         shell and then run DejaGnu.
  5. #
  6. # Written by Rob Savoye <rob@cygnus.com>
  7. #
  8.  
  9. #
  10. # Get the execution path to this script and the current directory.
  11. #
  12. mypath=${0-.}
  13. if expr ${mypath} : '.*/.*' > /dev/null
  14. then
  15.     :
  16. else
  17.     IFS="${IFS=     }"; save_ifs="$IFS"; IFS="${IFS}:"
  18.     for dir in $PATH
  19.     do
  20.     test -z "$dir" && dir=.
  21.     if test -x $dir/$mypath
  22.     then
  23.         mypath=$dir/$mypath
  24.         break
  25.     fi
  26.     done
  27.     IFS="$save_ifs"
  28. fi
  29. execpath=`echo ${mypath} | sed  -e 's@/[^/]*$@@'`
  30. # rootme=`pwd`
  31.  
  32. #
  33. # get the name by which runtest was invoked and extract the config triplet
  34. #
  35. runtest=`echo ${mypath} | sed -e 's@^.*/@@'`
  36. target=`echo $runtest | sed -e 's/-runtest$//'`
  37. if [ "$target" != runtest ] ; then
  38.     target="--target ${target}"
  39. else
  40.     target=""
  41. fi
  42.  
  43. #
  44. # Find the right expect binary to use. If a variable EXPECT exists,
  45. # it takes precedence over all other tests. Otherwise look for a freshly
  46. # built one, and then use one in the path.
  47. #
  48. if [ x"$EXPECT" != x ] ; then
  49.   expectbin=$EXPECT
  50. else
  51.   if [ -x "$execpath/expect" ] ; then
  52.     expectbin=$execpath/expect
  53.   else
  54.       expectbin=expect
  55.     fi
  56. fi
  57.  
  58. # just to be safe...
  59. if [ -z "$expectbin" ]; then
  60.   echo "ERROR: No expect shell found"
  61.   exit 1
  62. fi
  63.  
  64. #
  65. # Extract a few options from the option list.
  66. #
  67. verbose=0
  68. debug=""
  69. for a in "$@" ; do
  70.   case $a in        
  71.       -v|--v|-verb*|--verb*)    verbose=`expr $verbose + 1`;;
  72.       -D0|--D0)       debug="-D 0" ;;
  73.       -D1|--D1)       debug="-D 1" ;;
  74.   esac
  75. done
  76.  
  77. if expr $verbose \> 0 > /dev/null ; then
  78.   echo Expect binary is $expectbin
  79. fi
  80.  
  81. #
  82. # find runtest.exp. First we look in it's installed location, otherwise
  83. # start if from the source tree.
  84. #
  85. # runtest.exp is found in (autoconf-configure-set) @datadir@, but
  86. # $execpath is @bindir@.  We're assuming that 
  87. #
  88. # @datadir@ == @bindir@/../share
  89. # or
  90. # @datadir@ == @bindir@/../../share
  91. #
  92. # which is a very weak assumption
  93. #
  94. for i in `echo ${execpath} | sed  -e 's@/[^/]*$@/share/dejagnu@'` `echo ${execpath} | sed  -e 's@/[^/]*/[^/]*$@/share/dejagnu@'` $execpath ; do
  95.     if expr $verbose \> 1 > /dev/null ; then
  96.     echo Looking for $i/runtest.exp.
  97.     fi  
  98.     if [ -f $i/runtest.exp ] ; then
  99.     runpath=$i
  100.     if expr $verbose \> 0 > /dev/null ; then
  101.         echo Using $i/runtest.exp as main test driver
  102.     fi
  103.     fi
  104. done
  105. # check for an environment variable
  106. if [ x"$DEJAGNULIBS" != x ] ; then
  107.     runpath=$DEJAGNULIBS
  108.     if expr $verbose \> 0 > /dev/null ; then
  109.     echo Using $DEJAGNULIBS/runtest.exp as main test driver
  110.     fi
  111. fi
  112. if [ x"$runpath" = x ] ; then
  113.     echo "ERROR: runtest.exp does not exist."
  114.     exit 1
  115. fi
  116.  
  117. exec $expectbin $debug -- $runpath/runtest.exp $target ${1+"$@"}
  118.